package com.hmyuan.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hmyuan.dao.CategoryMapper;
import com.hmyuan.domain.Category;
import com.hmyuan.service.CategoryService;
@Service("categoryService")
public class CategoryServiceImpl implements CategoryService {
	@Resource
	CategoryMapper categoryMapper;
	
	@Override
	public PageInfo<Category> selectListByPage(Category category,
			int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, pageSize); // 核心分页代码
		List<Category> list = categoryMapper.selectList(category);
		PageInfo<Category> pageInfo = new PageInfo<Category>(list);
		
		return pageInfo;
	}

	@Override
	public boolean insert(Category category) {
		// TODO Auto-generated method stub
		int num = categoryMapper.insert(category);
		return num==1?true:false;
	}

	@Override
	public Category selectByPrimaryKey(Long id) {
		// TODO Auto-generated method stub
		return categoryMapper.selectByPrimaryKey(id);
	}

	@Override
	public boolean updateByPrimaryKeySelective(Category category) {
		// TODO Auto-generated method stub
		int num = categoryMapper.updateByPrimaryKeySelective(category);
		return num==1?true:false;
	}

	@Override
	public boolean deletecategoryById(Long id) {
		// TODO Auto-generated method stub
		int num = categoryMapper.deleteByPrimaryKey(id);
		return num==1?true:false;
	}

	@Override
	public List<Category> selectList(Category category) {
		// TODO Auto-generated method stub
		return categoryMapper.selectList(category);
	}

	@Override
	public List<Category> selectListByArticleid(Long articleid) {
		// TODO Auto-generated method stub
		return categoryMapper.selectListByArticleid(articleid);
	}

	@Override
	public List<Category> selectListWithCount() {
		// TODO Auto-generated method stub
		return categoryMapper.selectListWithCount();
	}
}
